﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Xml.Linq;

namespace Smart
{
    public class AppRegistry
    {
        /// <summary>
        /// 静态实例
        /// </summary>
        static AppRegistry()
        {
            lock (sync)
            {
                if (Instance == null)
                {
                    lock (sync)
                    {
                        Instance = new AppRegistry();
                    }
                }
            }
        }

        /// <summary>
        /// 不允许创建实例
        /// </summary>
        private AppRegistry() { }

        public static AppRegistry Instance { get; protected set; }
        private static object sync = new object();
        private static readonly long IsolatedStorageQuota = 100 * 1024 * 1024;

        public XElement LoginInfo { get; set; }

        public bool IsolatedStorage(string key)
        {
            using (var store =
            System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForApplication())
            {
                ///小于指定配额的情况下，增加到指定配额
                if (store.Quota < IsolatedStorageQuota)
                {
                    store.IncreaseQuotaTo(IsolatedStorageQuota);
                }
            }
            return true;
        }
    }
}
